//
//  UIView+ModalAnimation.m
//  Malena
//
//  Created by Dawn on 12-11-3.
//  Copyright (c) 2012年 Dawn. All rights reserved.
//

#import "UIView+ModalAnimation.h"


@implementation UIView (ModalAnimation)

+(void) commitModalAnimations{
	CFRunLoopRef currentLoop = CFRunLoopGetCurrent();
	UIViewModalAnimationDelegate *viewDelegate = [[UIViewModalAnimationDelegate alloc] initWithRunLoop:currentLoop];
	[UIView setAnimationDelegate:viewDelegate];
	[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
	[UIView commitAnimations];
	CFRunLoopRun();
	[viewDelegate release];
}

@end

@implementation UIViewModalAnimationDelegate

-(id) initWithRunLoop:(CFRunLoopRef)runLoop{
	if (self= [super init]) {
		currentLoop = runLoop;
		return self;
	}
	return nil;
}

-(void) animationFinished:(id)sender{
	CFRunLoopStop(currentLoop);
}

@end

